package com.onstar.cn.function;

import android.content.Context;

import com.onstar.cn.Utils;


/**
 * Created by Rengui Lu on 2016/8/2.
 */

public class FunctionInfo {

    private int id;

    private int orderInHotseat;

    private String functionType;

    private String vin;//

    private Integer functionOrder;// 功能序号
    private boolean isInHotseat;


    private String title;
    private Integer iconResId;
    private String fragment;
    private String activity;// 跳转Activity

    private String functionNameFindId;

    public String getFunctionNameFindId() {
        return functionNameFindId;
    }

    public void setFunctionNameFindId(String functionNameFindId) {
        this.functionNameFindId = functionNameFindId;
    }



    public FunctionInfo() {

    }

    public FunctionInfo(int id, int orderInHotseat, String functionType, String vin, int functionOrder, String title, boolean isInHotseat, int iconResId, String fragment, String activity,String functionNameFindId) {
        this.id = id;
        this.orderInHotseat = orderInHotseat;
        this.functionType = functionType;
        this.vin = vin;
        this.functionOrder = functionOrder;
        this.title = title;
        this.isInHotseat = isInHotseat;
        this.iconResId = iconResId;
        this.fragment = fragment;
        this.activity = activity;
        this.functionNameFindId = functionNameFindId;
    }


    @Override
    public Object clone() throws CloneNotSupportedException {
        FunctionInfo functionInfo = new FunctionInfo(id, orderInHotseat, functionType, vin, functionOrder, title, isInHotseat, iconResId, fragment, activity,functionNameFindId);
        return functionInfo;
    }

    @Override
    public boolean equals(Object other) {
        if(this == other)                                      //先检查是否其自反性，后比较other是否为空。这样效率高
            return true;
        if(other == null)
            return false;
        if( !(other instanceof FunctionInfo))
            return false;
        final FunctionInfo cat = (FunctionInfo) other;

        return (getFunctionType() + "").equalsIgnoreCase(cat.getFunctionType() + "") && (getFunctionOrder() + "").equalsIgnoreCase(cat.getFunctionOrder() + "");
    }

    @Override
    public String toString() {
        return "title=" + title + ",isInHotseat=" + isInHotseat + ",orderInHotseat=" + orderInHotseat;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getOrderInHotseat() {
        return orderInHotseat;
    }

    public void setOrderInHotseat(int orderInHotseat) {
        this.orderInHotseat = orderInHotseat;
    }

    public String getFunctionType() {
        return functionType;
    }

    public void setFunctionType(String functionType) {
        this.functionType = functionType;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public Integer getFunctionOrder() {
        return functionOrder;
    }

    public void setFunctionOrder(Integer functionOrder) {
        this.functionOrder = functionOrder;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isInHotseat() {
        return isInHotseat;
    }

    public void setInHotseat(boolean inHotseat) {
        isInHotseat = inHotseat;
    }

    public Integer getIconResId() {
        return iconResId;
    }

    public void setIconResId(Integer iconResId) {
        this.iconResId = iconResId;
    }

    public String getFragment() {
        return fragment;
    }

    public void setFragment(String fragment) {
        this.fragment = fragment;
    }

    public String getActivity() {
        return activity;
    }

    public void setActivity(String activity) {
        this.activity = activity;
    }

    public static final int RemoteControl = 0;
    public static final int VehicleState = 1;
    public static final int Navigation = 2;
    public static final int VehicleControl = 3;
    public static final int VistorServices = 4;

    public static String getFunctionTypeDesc(Context context, int functionType) {
        switch (functionType) {
            case RemoteControl:
                return context.getResources().getString(Utils.getStringIdByDynamic(context, "function_type_remote"));
            case VehicleState:
                return context.getResources()
                        .getString(Utils.getStringIdByDynamic(context, "function_type_vehicle_service"));
            case Navigation:
                return context.getResources()
                        .getString(Utils.getStringIdByDynamic(context, "function_type_navigation"));
            case VehicleControl:
                return context.getResources()
                        .getString(Utils.getStringIdByDynamic(context, "function_type_vehicle_control"));
            case VistorServices:
                return context.getResources()
                        .getString(Utils.getStringIdByDynamic(context, "function_type_personal_services"));
            default:
                return "";
        }
    }
}
